//映射map
//(key value)
//使用操作符 ->
val scores
=
Map("Tom" -> 80, "Mike" -> 90, "Kalle" -> 100)


//可变的Map
val chinese
=
  scala.collection.mutable.Map("Tom" -> 80, "Mike" -> 90, "Kalle" -> 100)


chinese("Tom")

//判断时候有这个Jone的元素,如果有就返回其value,否则就返回-1
chinese.getOrElse("Jone", -1)
//上线两个是等价的
if (chinese.contains("Jone")) {
  chinese("Jone")
} else {
  -1
}







//更新某个元素的值
chinese.update("Tom", 100)
//获得某个元素
chinese("Tom")
//添加元素
chinese += "Jone" -> 95
//移除元素
chinese -= "Jone"


//迭代映射:for  foreach
for (s <- chinese) println(s._1 + s._2)

//取出映射的每个元素,并把这个元素传递给println
chinese.foreach(println)